/*
 * Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD.
 * All rights reserved.
 * Official Web Site: http://www.xiaominfo.com.
 * Developer Web Site: http://open.xiaominfo.com.
 */

package com.github.xiaoymin.map.model;

import cn.hutool.core.util.StrUtil;
import com.github.xiaoymin.map.exception.MapClientException;

/**
 * @author <a href="mailto:xiaoymin@foxmail.com">xiaoymin@foxmail.com</a>
 * 2020/09/21 14:32
 * @since:map-client 1.0
 */
public class AmapKey {
    /**
     * 开发秘钥
     */
    private String key;
    /**
     * 是否需要签名
     */
    private boolean sign;
    /**
     * 签名秘钥
     */
    private String signKey;

    /**
     * 构造高德地图开发信息key
     * @param key 开发秘钥
     * @param sign 是否需要数字签名
     * @param signKey 签名秘钥
     */
    public AmapKey(String key, boolean sign, String signKey) {
        this.key = key;
        this.sign = sign;
        this.signKey = signKey;
        //校验签名参数
        if (sign){
            if (StrUtil.isBlank(signKey)){
                throw new MapClientException("数字签名私钥不能为空");
            }
        }
    }

    public String getKey() {
        return key;
    }

    public boolean isSign() {
        return sign;
    }

    public String getSignKey() {
        return signKey;
    }
}
